<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function mirrorReverseArray(arr) {
      const length = arr.length;
      const middleIndex = Math.floor(length / 2);
      if (!length % 2 === 0) {
        // 数组长度为偶数，进行中间的对折翻转
        for (let i = 0; i < middleIndex; i++) {
          const mirrorIndex = length - i - 1;

          // 交换当前索引和镜像索引的项
          const temp = arr[i];
          arr[i] = arr[mirrorIndex];
          arr[mirrorIndex] = temp;
        }
      } else {
        // 数组长度为偶数，进行中间的对折翻转
        for (let i = 0; i < middleIndex; i++) {
          const mirrorIndex = length - i - 1;

          // 交换当前索引和镜像索引的项
          const temp = arr[i];
          arr[i] = arr[mirrorIndex];
          arr[mirrorIndex] = temp;
        }
      }
      return arr;
    }
    const inputArray = [1, 2, 13, 14, 21, 2, 26, 23];
    const resultArray = mirrorReverseArray(inputArray);
    console.log(resultArray); // [23, 22, 21, 14, 13, 12]
  </script>
</body>

</html>